package com.aaa.java07;

import com.aaa.utils.MyConstants;
import javafx.geometry.HorizontalDirection;

import java.time.Duration;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.util.Calendar;
import java.util.Date;

/**
 * @author ：Teacher陈（86521760@qq.com）
 * @date ：Created in 2022/7/8 14:09
 * @description：测试时间
 * @modified By：
 * @version: 1.0
 */
public class LocalDateTimeTest {
    /**
     * @create by: Teacher陈（86521760@qq.com）
     * @description: 字符串转localdatetime
     * @create time: 2022/7/8 15:23
     * @param time
     * @return
     */
    public static LocalDateTime fromStringToLocalDatetime(String time){
        LocalDateTime dateTime = LocalDateTime.parse(time);
        return dateTime;
    }
    /**
     * @create by: Teacher陈（86521760@qq.com）
     * @description: localdatetime转字符串转
     * @create time: 2022/7/8 15:23
     * @param time
     * @return
     */
    public static String fromLocalDatetimeToString(LocalDateTime time){
        DateTimeFormatter dateTimeFormatter= DateTimeFormatter.ofPattern(MyConstants.TIME_FORMAT);
        String s = dateTimeFormatter.format(time);
        return s;
    }


    public static void main(String[] args) {
        //获取当前系统时间
       /* LocalDateTime now = LocalDateTime.now();
        System.out.println(now);
        Date date  = new Date();
        System.out.println(date);
        System.out.println("当前的时区："+ ZoneId.systemDefault());
        //设置时区
       // now.atZone(ZoneId.systemDefault())
        int dayOfYear = now.getDayOfYear();
        //一年的第几天
        System.out.println(dayOfYear);*/

      /* //初始化一个生日
        LocalDate birthday = LocalDate.of(1999, 12, 10);
        System.out.println(birthday);
        //生辰八字
        LocalDateTime localDateTime1= LocalDateTime.of(1999,9,1,23,23,23);
        LocalDateTime localDateTime3= LocalDateTime.of(1999,9,1,23,23,23);
        LocalDateTime localDateTime2= LocalDateTime.of(1999,9,1,21,22,10);
        System.out.println(localDateTime1);
        //判断localDateTime1是否在localDateTime3之后
        boolean after = localDateTime1.isAfter(localDateTime3);
        System.out.println(after);
        Duration between = Duration.between(localDateTime2, localDateTime1);*/

     /* String xxx="1999-09-01T23:23:23";
        LocalDateTime localDateTime = LocalDateTimeTest.fromStringToLocalDatetime(xxx);
        System.out.println(localDateTime);*/

        LocalDateTime now = LocalDateTime.now();

        String s = fromLocalDatetimeToString(now);
        System.out.println(s);
    }
}
